package com.example.qj.demo.learn;

import com.example.qj.demo.util.KieBaseAndKieSessionFactory;
import org.junit.Test;
import org.kie.api.KieBase;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.process.ProcessInstance;
import org.kie.api.runtime.process.WorkflowProcessInstance;

import static org.junit.Assert.assertEquals;

public class BoundaryErrorOperation {

    /**
     * 测试错误边界事件，子流程结束节点抛出，自动触发。不会中断主流程的执行
     * @throws Exception
     */
    @Test
    public void boundaryErrorTest() throws Exception {

        KieBase kbase = KieBaseAndKieSessionFactory.createKnowledgeBase("boundaryErrorOperation.bpmn2");
        KieSession ksession = KieBaseAndKieSessionFactory.createKnowledgeSession(kbase);

        WorkflowProcessInstance processInstance = (WorkflowProcessInstance) ksession.startProcess("boundaryError",null );
        assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
    }

}
